import { Department } from "@/api/interface/department";
import { ResPage } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * 部门管理模块
 */

// 获取部门列表
export const getDepartmentListApi = (params?: { page?: number; pageSize?: number; search?: string }) => {
  return http.get<ResPage<Department.DepartmentItem>>(PORT1 + `/department/list`, params);
};

// 获取部门树形结构
export const getDepartmentTreeApi = () => {
  return http.get<Department.DepartmentItem[]>(PORT1 + `/department/tree`);
};

// 获取部门详情
export const getDepartmentDetailApi = (params: { FId: string }) => {
  return http.get<Department.DepartmentItem>(PORT1 + `/department/detail/${params.FId}`);
};

// 创建部门
export const createDepartmentApi = (params: Department.CreateDepartmentParams) => {
  return http.post<number>(PORT1 + `/department/create`, params);
};

// 更新部门
export const updateDepartmentApi = (params: Department.UpdateDepartmentParams) => {
  return http.post<boolean>(PORT1 + `/department/update/${params.id}`, params);
};

// 删除部门
export const deleteDepartmentApi = (params: Department.DeleteDepartmentParams) => {
  return http.post<boolean>(PORT1 + `/department/delete`, params);
};
